<script type="text/javascript">
chns = new Array();
<%
  object oUser = dom.GetObject( system.GetSessionVar("sessionUserID") );
  if ( oUser ) 
  {
    string sID;
    foreach( sID, oUser.UserTempViewIDs2().EnumEnabledIDs(system.GetSessionVar("sessionIdx"), 5) ) 
    {
      object chn = dom.GetObject(sID);
      if (chn) 
      {
        object oDev = dom.GetObject(chn.Device());
        if ( (chn.Name() != "") && (oDev.ReadyConfig() == false) && (chn.Internal() == false) ) 
        {
          object dev = dom.GetObject(chn.Device());
          string sIface = "";
          integer iface = dev.Interface();
          if (iface != ID_ERROR)
          {
            sIface = dom.GetObject(iface).Name();
          }
          Write("var tmp = new Object();");
          Write("tmp['name'] = '"#chn.Name()#"';");
          Write("tmp['id'] = "#chn.ID()#";");
          Write("tmp['type'] = '"#chn.Label()#"';");
          Write("tmp['devtype'] = '"#dev.Label()#"';");
          Write("tmp['desc'] = DEV_getDescription('"#dev.Label()#"');");     
          Write("tmp['sn'] = '"#chn.Address()#"';");
          string category = "";
          if (chn.ChnDirection() == 1) {category = 'lblSender';}
          if (chn.ChnDirection() == 2) {category = 'lblReceiver';}
          Write("tmp['iface'] = translateKey('"#category#"');");
          Write("tmp['deviface'] = '"#sIface#"';");
          Write("tmp['transOp'] = '"#chn.ChnAESOperation()#"';");
          Write("tmp['trans'] = ("#chn.ChnAESActive()#" ? translateKey('lblSecured') : translateKey('lblStandard') );");
          string functions = "";
          string funcTmp = "";
          foreach(funcTmp, chn.ChnFunction())
          {
            object objTmp = dom.GetObject(funcTmp);
            functions = functions #"${"# objTmp.Name() # "};";
          }
          Write("tmp['func'] = translateString('"#functions#"');");
          string rooms = "";
          string roomTmp = "";
          foreach(roomTmp, chn.ChnRoom())
          {
            object objTmp = dom.GetObject(roomTmp);
            rooms = rooms # objTmp.Name() # ";";
          }
          Write("tmp['room'] = '"#rooms#"';");
          Write("tmp['action'] = '';");
          Write("tmp['links'] = '';");
          Write("tmp['ready'] = "#chn.ReadyConfig()#";");
          boolean bFound3 = false;
          object oDpTmp = dom.GetObject( chn.DefaultDPWrite() );
          if( oDpTmp )
          {
            if( (!oDpTmp.IsTypeOf( OT_VARDP )) && (!oDpTmp.IsTypeOf( OT_ALARMDP )) )
            {
              bFound3 = true;
            }
          }
          if( bFound3 )
          {
            boolean bHasFullAccess = (chn.UserAccessRights(iulOtherThanAdmin) == iarFullAccess);
            if( bHasFullAccess )
            {
              Write("tmp['handle'] = 'YES';");
            }
            else
            {
              Write("tmp['handle'] = 'NO';");
            }
          }
          else
          {
            Write("tmp['handle'] = 'READONLY';");
          }
          Write("tmp['vis'] = "#(chn.Visible())#";");
          Write("tmp['proto'] = "#(chn.ChnArchive())#";");
          Write("tmp['chnNr'] = "#(chn.ChnNumber())#";");
          
          if( chn.ExistComTestDP() )
          {
            Write("tmp['comtestdp'] = true;");
          }
          else
          {
            Write("tmp['comtestdp'] = false;");
          }
          
          string s;
          foreach(s,dom.TestRunningIDs().EnumIDs())
          {
            if( s == chn.ID().ToString() )
            {
              Write("tmp['testrunning'] = true;");
            }
            else
            {
              Write("tmp['testrunning'] = false;");
            }
          }
          
          string sTimestamp = chn.TestCompletedTime();
          Call("/esp/TimeStamp.fn::TimeStampToString3()");
          Write("tmp['testtime'] = '"#sTimestamp#"';");

          
          Write("chns[chns.length] = tmp;");
        }
      }
    }
  }
%>
 
  for(var i = 0; i < chns.length; i++)
  {
    var tr = Builder.node("tr");
    
    td = Builder.node('td', {className: 'GrayBkg'}, chns[i]['type']); tr.appendChild(td);
    
    //td = Builder.node('td', {className: 'WhiteBkg'});
    td = Builder.node('td', {className: 'WhiteBkgPic'}, [
      Builder.node('div', {id: 'picDiv' + chns[i]['id'], className: "CLASS04500",
        onmouseover:"picDivShow(jg_250, '"+chns[i]['devtype']+"', 250, "+chns[i]['chnNr']+", this);", onmouseout:"picDivHide(jg_250);"})
    ]); 
    Element.addClassName(td, "CLASS04501");
    tr.appendChild(td);
    
    td = Builder.node('td', {className: 'GrayBkg'}, chns[i]['desc']); tr.appendChild(td);
    td = Builder.node('td', {className: 'GrayBkg'}, chns[i]['sn']); tr.appendChild(td);
    td = Builder.node('td', {className: 'GrayBkg'}, chns[i]['iface']); tr.appendChild(td);
    
    var s = "WhiteBkg";
    var sClick = "";
    var sCur = "";
    if (chns[i]['transOp'] < 3)
    {
      s = "GrayBkg";
    }
    else
    {
      sClick = 'CreatePopup(ID_TRANSFER_PARAMETERS, '+chns[i]['id']+ ')';
      sCur = " CLASS04503";
    }
    
    td = Builder.node('td', {className: s}, 
      [Builder.node('div', {className: "CLASS04502" + sCur, onclick: sClick}, chns[i]['trans']) ]); tr.appendChild(td);
    
    if (NAV_IE) {
      td = Builder.node('td', {className: 'WhiteBkg'}, 
          [Builder.node('div', {id:'tdn' + chns[i]['id'], className: "CLASS04502 CLASS04503", onclick: 'textEdit(id, '+chns[i]['id']+', false, 0)'}, chns[i]['name']) ]); tr.appendChild(td);
    }
    else {
      td = Builder.node('td', {className: 'WhiteBkg CLASS04503', id:'tdn' + chns[i]['id'], onclick: 'textEdit(id, '+chns[i]['id']+', false, 0)'}, chns[i]['name']); tr.appendChild(td);
    }  
      
    if (NAV_IE) {
      var tdId = "func" + chns[i]['id'];
      td = Builder.node('td', {id: tdId, className: 'WhiteBkg'}, 
        [Builder.node('div', {id: 'funcsDiv' + chns[i]['id'], className: "CLASS04502 CLASS04503", onclick: "showFuncOverlay(\'"+tdId+"\', \'"+chns[i]['id']+"\')"}, semCut(chns[i]['func'])) ]); tr.appendChild(td);
      var tdId = "room" + chns[i]['id'];
      td = Builder.node('td', {id: tdId, className: 'WhiteBkg'}, 
        [Builder.node('div', {id: 'roomsDiv' + chns[i]['id'], className: "CLASS04502 CLASS04503", onclick: "showRoomOverlay(\'"+tdId+"\', \'"+chns[i]['id']+"\')"}, semCut(chns[i]['room'])) ]); tr.appendChild(td);
    }
    else {
      td = Builder.node('td', {id: 'funcsDiv' + chns[i]['id'], className: 'WhiteBkg CLASS04503', onclick: "showFuncOverlay(\'funcsDiv"+chns[i]['id']+"\', \'"+chns[i]['id']+"\')"}, semCut(chns[i]['func'])); tr.appendChild(td);
      td = Builder.node('td', {id: 'roomsDiv' + chns[i]['id'], className: 'WhiteBkg CLASS04503', onclick: "showRoomOverlay(\'roomsDiv"+chns[i]['id']+"\', \'"+chns[i]['id']+"\')"}, semCut(chns[i]['room'])); tr.appendChild(td);
    }
    td = Builder.node('td', {className: 'WhiteBkg'}, ''); 
    
    writeTestField(td, chns[i]['id'].toString(),chns[i]['testtime'],chns[i]['comtestdp'],chns[i]['testrunning']);
    
    tr.appendChild(td);
    td = Builder.node('td', {className: 'WhiteBkg'}, ''); 
    writeDeviceAction(td, true, false, false, chns[i]);
    tr.appendChild(td);
    td = Builder.node('td', {className: 'GrayBkg'}, ''); 
    var sInpId = "inp" + chns[i]['id'];
    var input = Builder.node('input', {id: sInpId, type: 'checkbox', onclick: "iseChannels.setReadyConfig(this,"+chns[i]['id']+")"});
    input.checked = chns[i]['ready'];
    input._isReady = chns[i]['ready'];
    td.appendChild(input);
    tr.appendChild(td);  
    
    if ($("tblNewDevChns"))
      $("tblNewDevChns").appendChild(tr);
    // draw pic
    var jg_0 = new jsGraphics('picDiv' + chns[i]['id']);
    InitGD(jg_0, 50);
    Draw(jg_0, chns[i]['devtype'], 50, chns[i]['chnNr']);
    Cursor.set(Cursor.NORMAL);
  }
  
</script>
